#define _CRT_SECURE_NO_WARNINGS 1



#include<stdio.h>

int leap_year(int y)
{
	if ((y % 4 == 0 && y % 100 != 0) && y % 400 == 0)
		return 1;
	else
		return 0;
}
int main()
{
	int year = 0, month = 0, day = 0;
	while (scanf("%d/%d/%d", &year, &month, &day) != EOF)
	{
		int i = 0, sum = 0, arr[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
		if (leap_year(year) == 1)
			arr[2]++;
		for (i = 0; i < month; i++)
			sum += arr[i];
		printf("%d\n", sum + day);
	}

	return 0;
}